import java.io.*;
import java.util.*;
class Solution{

    /**
     * 删除指定字符串中的字符
     * @param args
     * @throws IOException
     * https://www.nowcoder.com/practice/f0db4c36573d459cae44ac90b90c6212?tpId=182&tqId=34789&ru=/exam/oj
     */
    public static void main1(String[] args)throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String s1 = br.readLine();
        String s2 = br.readLine();

        int len = s1.length();
        int[] hash = new int[128];

        for(int i = 0;i < s2.length();i++) hash[s2.charAt(i)]++;

        for(int j = 0;j < len;j++)
            if(hash[s1.charAt(j)] == 0) System.out.print(s1.charAt(j));
    }

    /**
     * 求公共节点
     *https://www.nowcoder.com/practice/6ab1d9a29e88450685099d45c9e31e46?tpId=13&tqId=11189&ru=/exam/oj
     */
    static class ListNode{
        int val;
        ListNode next;

        public ListNode(int val) {this.val = val;}
    }
    public ListNode FindFirstCommonNode1(ListNode pHead1, ListNode pHead2) {
        ListNode p1 = pHead1,p2 =pHead2;

        while(p1 != p2){
            p1 = p1 != null ? p1 = p1.next :  pHead2;
            p2 = p2 != null ? p2 = p2.next :  pHead1;
        }

        return p1;
    }

    public ListNode FindFirstCommonNode2(ListNode pHead1, ListNode pHead2) {
        ListNode p1 = pHead1,p2 =pHead2;

        //qiu长度
        int len1 = 0,len2 = 0;
        while(p1 != null){
            p1 = p1.next;
            len1++;
        }
        p1 = pHead1;
        while(p2 != null){
            p2 = p2.next;
            len2++;
        }
        p2 = pHead2;


        if(len1 < len2){
            int len = len1;
            len1 = len2;
            len2 = len;

            ListNode tem = p1;
            p1 = p2;
            p2 = tem;
        }

        //不能放在if里面，可能len1 》 len2
        int n = len1 - len2;
        while(n-- != 0) p1 = p1.next;


        while(p1 != null && p2 != null){
            if(p1.val == p2.val) return p1;
            p1 = p1.next;
            p2 = p2.next;
        }

        return p1;
    }

    /**
     * 获取字符串中子串出现的次数
     * https://ac.nowcoder.com/acm/problem/26226
     * 时间复杂度：O(N)
     * 空间复杂度：O（1）
     */

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long s = 0, h = 0, y = 0;

        int n = Integer.parseInt(in.nextLine());
        char[] ch = in.nextLine().toCharArray();

        for (int i = 0; i < n; i++) {
            if (ch[i] == 's') s++;
            else if (ch[i] == 'h') h += s;
            else if (ch[i] == 'y') y += h;
        }

        System.out.println(y);
    }
}